export interface AnyMessage {
    type: 'request' | 'response'
    id: string
    time: number
    action: string
    body: any
}

export interface RequestMessage extends AnyMessage {
    type: 'request'
}

export interface ResponseMessage extends AnyMessage {
    type: 'response'
}

export interface HeartBeatRequest extends RequestMessage {
    action: 'heartBeat'
}

export interface HeartBeatResponse extends ResponseMessage {
    action: 'heartBeat'
}

export interface LoginRequest extends RequestMessage {
    action: 'login'
    body: {
        token: string
    }
}

export interface LoginResponse extends ResponseMessage {
    action: 'login'
    body: {
        errorCode: number,
        errorMessage?: string
    }
}

export interface ConnectedRequest extends RequestMessage {
    action: 'connected'
    body: {
        clientId: string
    }
}

export interface ConnectedResponse extends ResponseMessage {
    action: 'connected'
    body: {
        ssss: string
    }
}